package com.dingwei.superiordiary.mvp.presenter;

import com.dingwei.superiordiary.base.MyBaseBean;
import com.dingwei.superiordiary.bean.FailsBean;
import com.dingwei.superiordiary.custom.myCallback;
import com.dingwei.superiordiary.mvp.view.Contract;
import com.lihao.baselibrary.base.BaseActivity;
import com.lihao.baselibrary.base.URLS;
import com.lihao.baselibrary.base.basePresenter;

import org.xutils.http.RequestParams;
import org.xutils.x;

/**
 * Created by lihao on 2017/9/12.
 */

public class ModifyIdiographPresenter extends basePresenter {

    private Contract.ModifyIdiographView modifyIdiographView;

    public ModifyIdiographPresenter(Contract.ModifyIdiographView view) {
        super(view);
        this.modifyIdiographView = view;
    }

    public void saveName(final String idiograph) {

        RequestParams rp =new RequestParams(URLS.HOST+URLS.EDIT_USER_DATA);
        rp.addBodyParameter("sessionid", BaseActivity.value.getToken());
        rp.addBodyParameter("idiograph",idiograph);
        x.http().post(rp, new myCallback(BaseActivity.context,MyBaseBean.class,rp) {
            @Override
            public void back(MyBaseBean baseBean, String result) {
                showToast(baseBean.message);
                modifyIdiographView.saveIdiographSuccess(idiograph);
            }

            @Override
            public void fail(FailsBean baseBean, String result) {

            }
        });
    }
}
